
var g_PEWindowObject;
var g_PEWindowDictionary = new Dictionary();

function getReadSMSTrackingStr() {
    var r = getHexE01ReadString(
			EnumE01Offset.TrackerPassword, 4)
			+ getHexE01ReadString(
					EnumE01Offset.SMSTrackInterval,
					2)
			+ getHexE01ReadString(
					EnumE01Offset.SMSTrackTimes, 2)
			+ getHexE01ReadString(
					EnumE01Offset.TrackingNumber,
					16);
    return r;
}

function getReadGPRSTrackingStr() {
    var r = getHexE01ReadString(EnumE01Offset.GPRSConnectWay, 1)
									+ getHexE01ReadString(
											EnumE01Offset.EngineCheck, 1)
									+ getHexE01ReadString(
											EnumE01Offset.TrackInterval, 2)
									+ getHexE01ReadString(
											EnumE01Offset.EngineOffInterval, 2)
									+ getHexE01ReadString(
											EnumE01Offset.TrackTimes, 2)
									+ getHexE01ReadString(EnumE01Offset.IP1, 32)
									+ getHexE01ReadString(EnumE01Offset.Port1,
											5)
									+

									getHexE01ReadString(EnumE01Offset.IP2, 32)
									+ getHexE01ReadString(EnumE01Offset.Port2,
											5)
									+ getHexE01ReadString(EnumE01Offset.APN, 32)
									+ getHexE01ReadString(
											EnumE01Offset.APNUserName, 32)
									+ getHexE01ReadString(
											EnumE01Offset.APNPassword, 32)
									+ getHexE01ReadString(
											EnumE01Offset.TrackerID, 16);
    return r;
}


function getReadGPRSTracking1Str() {
    var r = getHexE01ReadString(EnumE01Offset.GPRSAuth, 16);
    return r;
}


function getReadMainStr() {
    var r = getHexE01ReadString(EnumE01Offset.ProtocolType,1)
            +getHexE01ReadString(EnumE01Offset.SMSTimeZone, 4)
			+ getHexE01ReadString(EnumE01Offset.GPRSTimeZone, 4)
			+ getHexE01ReadString(EnumE01Offset.DistanceInterval, 4)
			+ getHexE01ReadString(EnumE01Offset.Turn, 2)
			+ getHexE01ReadString(EnumE01Offset.MaxSpeed, 2)
			+ getHexE01ReadString(EnumE01Offset.ExternalPowerLow, 2)
			+ getHexE01ReadString(EnumE01Offset.Heartbeat, 2)
			+ getHexE01ReadString(EnumE01Offset.LogInteravl, 2)
			+ getHexE01ReadString(EnumE01Offset.Tow, 1)
            +getHexE01ReadString(EnumE01Offset.AccInputGPSleep, 1)
            +getHexE01ReadString(EnumE01Offset.LEDOff, 1)
            +getHexE01ReadString(EnumE01Offset.BuzzerOff, 1);
    return r;
}

function getReadGeoFenceStr() {
    var r = getHexE01ReadString(EnumE01Offset.GeoFence, 16*8);
    return r;
}

function getReadSMSAuthStr() {
    var r = getHexE01ReadString(EnumE01Offset.SMSAuth, 32 * 5);
    return r;
}

function getReadEventHeaderStr() {
    var r = getHexE01ReadString(
			"0340", 16)
			+ getHexE01ReadString("0350", 16)
			+ getHexE01ReadString("0360", 16)
			+ getHexE01ReadString("0370", 16)
			+ getHexE01ReadString("0380", 16)
			+ getHexE01ReadString("03C0", 16)
			+ getHexE01ReadString("03D0", 16)
			+ getHexE01ReadString("03E0", 16)
			+ getHexE01ReadString("03F0", 16)
			+ getHexE01ReadString("0400", 16)
			+ getHexE01ReadString("0440", 16)
			+ getHexE01ReadString("0450", 16)
			+ getHexE01ReadString("0460", 16)
			+ getHexE01ReadString("0470", 16)
			+ getHexE01ReadString("0480", 16)
			+ getHexE01ReadString("0490", 16)
			+ getHexE01ReadString("04A0", 16)
			+ getHexE01ReadString("04B0", 16)
			+ getHexE01ReadString("04C0", 16)
			+ getHexE01ReadString("04D0", 16)
			+ getHexE01ReadString("04E0", 16)
			+ getHexE01ReadString("04F0", 16)
			+ getHexE01ReadString("0500", 16)
			+ getHexE01ReadString("0510", 16)
			+ getHexE01ReadString("0540", 16)
			+ getHexE01ReadString("0550", 16)
			+ getHexE01ReadString("0560", 16)
			+ getHexE01ReadString("0570", 16);
    return r;
}

function getReadPhotoAuthStr() {
    var r = getHexE01ReadString(EnumE01Offset.PhotoAuth, 16);
    return r;
}

function ParamEditorWin(sssid,trackername){
    var txtPassword = createNewParamTextFieldEx(120, 10, false, 4);
    txtPassword.setValue('0000');
    var txtTrackingNumber = createNewParamTextFieldEx(120, 40, false, 16);
    var txtTimeInterval = createNewParamNumberFieldEx(120, 70, false);
    txtTimeInterval.setValue(0);
    var txtTrackingCount = createNewParamNumberFieldEx(120, 100, false);
    txtTrackingCount.setValue(0);

    var lblPasssword = createNewParamLableEx(5, 15, _ImageButtonText_TrackerPassword);
    var lblNumber = createNewParamLableEx(5, 45, _SettingTool_SMSTrackingNumber);
    var lblTimeInterval = createNewParamLableEx(5, 75,_SettingTool_SMSTrackingInterval);
    var lblTrackingCount = createNewParamLableEx(5, 105,_SettingTool_SMSTrackingTimes);

    // GPRS追踪tab
    var GPRSConnectModelStore = new Ext.data.ArrayStore({
        fields: ['id', 'text'],
        data: [[0, _TrackerMain_Off], [1, _SettingTool_TCP], [2, _SettingTool_UDP]]
    });

    var cmbGPRSConnectModel = createComboBoxForCommandEx(140, 10, GPRSConnectModelStore, 'id', 'text', 100);
    
    cmbGPRSConnectModel.setValue(1);
    var txtGPRSInterval = createNewParamNumberFieldEx(140, 40, false);
    txtGPRSInterval.setValue(0);
    var txtEngineClosedUploadInterval = createNewParamNumberFieldEx(140, 70, false);
    txtEngineClosedUploadInterval.setValue(0);
    var chkIgnitionOff = new Ext.form.Checkbox({
        x: 310,
        y: 70

    });
    chkIgnitionOff.addListener('check', function() {
        if (chkIgnitionOff.getValue()) {
            txtEngineClosedUploadInterval.setReadOnly(true);
            txtEngineClosedUploadInterval.setDisabled(true);
        }
        else {
            txtEngineClosedUploadInterval.setReadOnly(false);
            txtEngineClosedUploadInterval.setDisabled(false);
        }
    });
     
    var txtGPRSTrackingCount = createNewParamNumberFieldEx(140, 100, false);
    txtGPRSTrackingCount.setValue(0);
    var txtIP = createNewParamTextFieldEx(140, 130, false, 16);
    var txtPort = createNewParamTextFieldEx(140, 160, false);
    var txtBackupIP = createNewParamTextFieldEx(140, 190, false);
    var txtBackupPort = createNewParamTextFieldEx(140, 220, false);
    var txtAPN = createNewParamTextFieldEx(140, 250, false);
    var txtAPNUserName = createNewParamTextFieldEx(140, 280, false);
    var txtAPNPassword = createNewParamTextFieldEx(140, 310, false);
    var txtDeviceNumber = createNewParamTextFieldEx(140, 340, true);

    var lblGPRSConnectModel = createNewParamLableEx(5, 15, _SettingTool_GPRSConnectionModel);
    var lblGPRSTrackingInterval = createNewParamLableEx(5, 45, _SettingTool_GPRSTractingInterval);
    var lblEngineClosedUploadInterval = createNewParamLableEx(5, 75, _SettingTool_EngineClosedUploadInterva);
    var lblGPRSTrackingCount = createNewParamLableEx(5, 105, _SettingTool_GPRSTracingUpNumber);
    var lblIP = createNewParamLableEx(5, 135, _SettingTool_IP);
    var lblPort = createNewParamLableEx(5, 165, _SettingTool_Port);
    var lblBackupIP = createNewParamLableEx(5, 195, _SettingTool_BackupIP);
    var lblBackupPort = createNewParamLableEx(5, 225, _SettingTool_Port);
    var lblAPN = createNewParamLableEx(5, 255, _ImageButtonText_Apn);
    var lblAPNUserName = createNewParamLableEx(5, 285, _SettingTool_APNUserName);
    var lblAPNPassword = createNewParamLableEx(5, 315, _SettingTool_APNPassword);
    var lblDeviceNumber = createNewParamLableEx(5, 350, _ImageButtonText_SnIMeiId);

    var GPRSStore = createEventCodeStoreEx(EnumAuthType.GPRS, false);

    var GPSRCheckbox = new Ext.grid.CheckColumn({
        // header : 'flag',
        dataIndex: 'choosed',
        width: 60
    });

    var GPRScm = new Ext.grid.ColumnModel([{
        header: _SettingTool_Event,
        width: 220,
        // sortable : true,
        dataIndex: 'val'

    }, GPSRCheckbox]);

    // 主要参数tab
    var EventReliableTransModeStore = new Ext.data.ArrayStore({

        fields: ['id', 'text'],
        data: [[0, _TrackerMain_AutoEventReport],
					[1, _SettingTool_EventNeedServiceCommand]]
    });
    var cmbProtocolType = createComboBoxForCommandEx(140, 10,EventReliableTransModeStore, 'id', 'text', 250);

    var txtTimeZone = createNewParamNumberFieldEx(140, 40, false);
    var txtGPRSZone = createNewParamNumberFieldEx(140, 70, false);
    var txtDistanceTractingInterval = createNewParamNumberFieldEx(140, 100, false);
    var txtAngleTurn = createNewParamNumberFieldEx(140, 130, false);
    var txtOverSpeedAlarm = createNewParamNumberFieldEx(140, 160, false);
    var txtExternalPowerLowValue = createNewParamNumberFieldEx(140, 190, false);
    var txtHeartbeatPacketInterval = createNewParamNumberFieldEx(140, 220, false);
    var txtRecorderInterval = createNewParamNumberFieldEx(140, 250, false);

    var SleepModelStore = new Ext.data.ArrayStore({

        fields: ['id', 'text'],
        data: [[0, _SettingTool_NomalSleep],
                [1, _SettingTool_DeepSleep],
				[2, _SettingTool_ConcelSleepModel]]
    });
    var cmbSleepModelEx = createComboBoxForCommandEx(495, 10, SleepModelStore, 'id','text', 150);
    var txtTowAlarmShakeTime = createNewParamNumberFieldEx(140, 280, false);
    var chkLEDOff = new Ext.form.Checkbox({
        x: 495,
        y: 40
    });
    var chkBuzzerOff = new Ext.form.Checkbox({
        x: 495,
        y: 70
    });

    // Gprs事件可靠传输方式和休眠模式没有

    var lblEventReliableTransMode = createNewParamLableEx(5, 15,_SettingTool_EventReliableTransMode);
    var lblTimeZone = createNewParamLableEx(5, 45, _SettingTool_TimeZone);
    var lblGPRSZone = createNewParamLableEx(5, 75, _SettingTool_GPRSZone);
    var lblDistanceTractingInterval = createNewParamLableEx(5, 105,_SettingTool_DistanceTractingInterval);
    var lblAngleTurn = createNewParamLableEx(5, 135, _SettingTool_AngleTurn);
    var lblOverSpeedAlarm = createNewParamLableEx(5, 165, _AlarmResource_OverSpeed);
    var lblExternalPowerLowValue = createNewParamLableEx(5, 195,_SettingTool_ExternalPowerLowValue);
    var lblHeartbeatPacketInterval = createNewParamLableEx(5, 225,	_SettingTool_HeartbeatPacketInterval);
    var lblRecorderInterval = createNewParamLableEx(5, 255,_SettingTool_RecorderInterval);
    var lblTowAlarmShakeTime = createNewParamLableEx(5, 285,_SettingTool_TowAlarmShakeTime);
    var lblSleepModel = createNewParamLableEx(400, 15, _SettingTool_SleepModel);
    var lblLED = createNewParamLableEx(400, 45, _SettingTool_LEDClose);
    var lblFMQ = createNewParamLableEx(400, 75, _SettingTool_FMQClose);

    // 电子围栏tab
    var txtLat1 = createNewParamNumberFieldEx(80, 40, false,90,-90,true,6);
    var txtLat2 = createNewParamNumberFieldEx(80, 70, false, 90, -90, true, 6);
    var txtLat3 = createNewParamNumberFieldEx(80, 100, false, 90, -90, true, 6);
    var txtLat4 = createNewParamNumberFieldEx(80, 130, false, 90, -90, true, 6);
    var txtLat5 = createNewParamNumberFieldEx(80, 160, false, 90, -90, true, 6);
    var txtLat6 = createNewParamNumberFieldEx(80, 190, false, 90, -90, true, 6);
    var txtLat7 = createNewParamNumberFieldEx(80, 220, false, 90, -90, true, 6);
    var txtLat8 = createNewParamNumberFieldEx(80, 250, false, 90, -90, true, 6);

    var txtLng1 = createNewParamNumberFieldEx(210, 40, false, 180, -180, true, 6);
    var txtLng2 = createNewParamNumberFieldEx(210, 70, false, 180, -180, true, 6);
    var txtLng3 = createNewParamNumberFieldEx(210, 100, false, 180, -180, true, 6);
    var txtLng4 = createNewParamNumberFieldEx(210, 130, false, 180, -180, true, 6);
    var txtLng5 = createNewParamNumberFieldEx(210, 160, false, 180, -180, true, 6);
    var txtLng6 = createNewParamNumberFieldEx(210, 190, false, 180, -180, true, 6);
    var txtLng7 = createNewParamNumberFieldEx(210, 220, false, 180, -180, true, 6);
    var txtLng8 = createNewParamNumberFieldEx(210, 250, false, 180, -180, true, 6);

    var txtRadius1 = createNewParamNumberFieldEx(340, 40, false, 4294967295,0,false,0);
    var txtRadius2 = createNewParamNumberFieldEx(340, 70, false, 4294967295, 0, false, 0);
    var txtRadius3 = createNewParamNumberFieldEx(340, 100, false, 4294967295, 0, false, 0);
    var txtRadius4 = createNewParamNumberFieldEx(340, 130, false, 4294967295, 0, false, 0);
    var txtRadius5 = createNewParamNumberFieldEx(340, 160, false, 4294967295, 0, false, 0);
    var txtRadius6 = createNewParamNumberFieldEx(340, 190, false, 4294967295, 0, false, 0);
    var txtRadius7 = createNewParamNumberFieldEx(340, 220, false, 4294967295, 0, false, 0);
    var txtRadius8 = createNewParamNumberFieldEx(340, 250, false, 4294967295, 0, false, 0);

    var checkboxEnterGEO1 = createNewParamCheckbox(510, 40);
    var checkboxEnterGEO2 = createNewParamCheckbox(510, 70);
    var checkboxEnterGEO3 = createNewParamCheckbox(510, 100);
    var checkboxEnterGEO4 = createNewParamCheckbox(510, 130);
    var checkboxEnterGEO5 = createNewParamCheckbox(510, 160);
    var checkboxEnterGEO6 = createNewParamCheckbox(510, 190);
    var checkboxEnterGEO7 = createNewParamCheckbox(510, 220);
    var checkboxEnterGEO8 = createNewParamCheckbox(510, 250);

    var checkboxExitGEO1 = createNewParamCheckbox(630, 40);
    var checkboxExitGEO2 = createNewParamCheckbox(630, 70);
    var checkboxExitGEO3 = createNewParamCheckbox(630, 100);
    var checkboxExitGEO4 = createNewParamCheckbox(630, 130);
    var checkboxExitGEO5 = createNewParamCheckbox(630, 160);
    var checkboxExitGEO6 = createNewParamCheckbox(630, 190);
    var checkboxExitGEO7 = createNewParamCheckbox(630, 220);
    var checkboxExitGEO8 = createNewParamCheckbox(630, 250);

    var LabelDZWL = createNewParamLableEx(5, 15, _SettingTool_ElectronicfenceCode);
    var LabelLat = createNewParamLableEx(120, 15, _Alarm_Header_Latitude);
    var LabelLng = createNewParamLableEx(250, 15, _Alarm_Header_Longitude);
    var LabelRa = createNewParamLableEx(370, 15, _SettingTool_Radius);
    var LabelEnterGEO = createNewParamLableEx(490, 15, _TrackerMain_InAlarm);
    var LabelExitGEO = createNewParamLableEx(610, 15, _TrackerMain_OutAlarm);

    var LabelLat1 = createNewParamLableEx(5, 45, "1");
    var LabelLat2 = createNewParamLableEx(5, 75, "2");
    var LabelLat3 = createNewParamLableEx(5, 105, "3");
    var LabelLat4 = createNewParamLableEx(5, 135, "4");
    var LabelLat5 = createNewParamLableEx(5, 165, "5");
    var LabelLat6 = createNewParamLableEx(5, 195, "6");
    var LabelLat7 = createNewParamLableEx(5, 225, "7");
    var LabelLat8 = createNewParamLableEx(5, 255, "8");

    // 授权号码tab
    var lblAuthNumber = createNewParamLableEx(25, 15,_SettingTool_AccreditNumber);
    var LabelListenerNumber = createNewParamLableEx(580, 15,_TrackerMain_ListeningNumber);
    // LabelListenerNumber.setWidth(45);
    var txtAuthNumber1 = createNewParamTextFieldEx(185, 10, false);
    var txtAuthNumber2 = createNewParamTextFieldEx(310, 10, false);
    var txtAuthNumber3 = createNewParamTextFieldEx(435, 10, false);
    var txtListenerNumber1 = createNewParamTextFieldEx(640, 10, false);
    var txtListenerNumber2 = createNewParamTextFieldEx(640, 40, false);

    var SMSStore = createEventCodeStoreEx(EnumAuthType.SMS, false);

    var SMSCheckbox1 = new Ext.grid.CheckColumn({
        // header : 'flag',
        dataIndex: 'choosed',
        width: 120
    });
    var SMSCheckbox2 = new Ext.grid.CheckColumn({
        // header : 'flag',
        dataIndex: 'choosed1',
        width: 120
    });
    var SMSCheckbox3 = new Ext.grid.CheckColumn({
        // header : 'flag',
        dataIndex: 'choosed2',
        width: 120
    });
    var SMScm = new Ext.grid.ColumnModel([{
        header: _SettingTool_Event,
        width: 180,
        // sortable : true,
        dataIndex: 'val'

    }, SMSCheckbox1, SMSCheckbox2, SMSCheckbox3]);

    // 短信事件字符tab
    var txtInput1Activate_Message = createNewParamTextFieldEx(130, 10, false);
    var txtInput2Activate_Message = createNewParamTextFieldEx(130, 40, false);
    var txtInput3Activate_Message = createNewParamTextFieldEx(130, 70, false);
    var txtInput4Activate_Message = createNewParamTextFieldEx(130, 100, false);
    var txtInput5Activate_Message = createNewParamTextFieldEx(130, 130, false);
    var txtInput1NotActivate_Message = createNewParamTextFieldEx(130, 160, false);
    var txtInput2NotActivate_Message = createNewParamTextFieldEx(130, 190, false);
    var txtInput3NotActivate_Message = createNewParamTextFieldEx(130, 220, false);
    var txtInput4NotActivate_Message = createNewParamTextFieldEx(130, 250, false);
    var txtInput5NotActivate_Message = createNewParamTextFieldEx(130, 280, false);
    var txtBuiltinLowVoltage_Message = createNewParamTextFieldEx(430, 10, false);
    var txtOutlayLowVoltage_Message = createNewParamTextFieldEx(430, 40, false);
    var txtOverSpeedAlarm_Message = createNewParamTextFieldEx(430, 70, false);
    var txtEnterGEO_Message = createNewParamTextFieldEx(430, 100, false);
    var txtExitGEO_Message = createNewParamTextFieldEx(430, 130, false);
    var txtOutlayPowerOn_Message = createNewParamTextFieldEx(430, 160, false);
    var txtOutlayPowerOff_Message = createNewParamTextFieldEx(430, 190, false);
    var txtNotFixGPRS_Message = createNewParamTextFieldEx(430, 220, false);
    var txtFixGPRS_Message = createNewParamTextFieldEx(430, 250, false);
    var txtEnterSleep_Message = createNewParamTextFieldEx(430, 280, false);
    var txtExitSleep_Message = createNewParamTextFieldEx(730, 10, false);
    var txtGPRSAntennaCut_Message = createNewParamTextFieldEx(730, 40, false);
    var txtReboot_Message = createNewParamTextFieldEx(730, 70, false);
    var txtCrashAlarm_Message = createNewParamTextFieldEx(730, 100, false);
    var txtDistanceTracing_Message = createNewParamTextFieldEx(730, 130, false);
    var txtDemandInfoNow_Message = createNewParamTextFieldEx(730, 160, false);
    var txtIntervalTracting_Message = createNewParamTextFieldEx(730, 190, false);
    var txtTowAlarm_Message = createNewParamTextFieldEx(730, 220, false);

    var LabelInput1Activate_Message = createNewParamLableEx(5, 15,_SettingTool_Input1Activate_Message);
    var LabelInput2Activate_Message = createNewParamLableEx(5, 45,_SettingTool_Input2Activate_Message);
    var LabelInput3Activate_Message = createNewParamLableEx(5, 75,_SettingTool_Input3Activate_Message);
    var LabelInput4Activate_Message = createNewParamLableEx(5, 105,_SettingTool_Input4Activate_Message);
    var LabelInput5Activate_Message = createNewParamLableEx(5, 135,_SettingTool_Input5Activate_Message);
    var LabelInput1NotActivate_Message = createNewParamLableEx(5, 165,_SettingTool_Input1NotActivate_Message);
    var LabelInput2NotActivate_Message = createNewParamLableEx(5, 195,_SettingTool_Input2NotActivate_Message);
    var LabelInput3NotActivate_Message = createNewParamLableEx(5, 225,_SettingTool_Input3NotActivate_Message);
    var LabelInput4NotActivate_Message = createNewParamLableEx(5, 255,_SettingTool_Input4NotActivate_Message);
    var LabelInput5NotActivate_Message = createNewParamLableEx(5, 285,_SettingTool_Input5NotActivate_Message);
    var LabelBuiltinLowVoltage_Message = createNewParamLableEx(340, 15,_SettingTool_BuiltinLowVoltage_Message);
    var LabelOutlayLowVoltage_Message = createNewParamLableEx(340, 45,_SettingTool_OutlayLowVoltage_Message);
    var lblOverSpeedAlarm_Message = createNewParamLableEx(340, 75,_SettingTool_OverSpeedAlarm_Message);
    var LabelEnterGEO_Message = createNewParamLableEx(340, 105,_SettingTool_EnterGEO_Message);
    var LabelExitGEO_Message = createNewParamLableEx(340, 135,_SettingTool_ExitGEO_Message);
    var LabelOutlayPowerOn_Message = createNewParamLableEx(340, 165,_SettingTool_OutlayPowerOn_Message);
    var LabelOutlayPowerOff_Message = createNewParamLableEx(340, 195,_SettingTool_OutlayPowerOff_Message);
    var LabelNotFixGPRS_Message = createNewParamLableEx(340, 225,_SettingTool_NotFixGPRS_Message);
    var LabelFixGPRS_Message = createNewParamLableEx(340, 255,_SettingTool_FixGPRS_Message);
    var LabelEnterSleep_Message = createNewParamLableEx(340, 285,_SettingTool_EnterSleep_Message);
    var LabelExitSleep_Message = createNewParamLableEx(640, 15,_SettingTool_ExitSleep_Message);
    var LabelGPRSAntennaCut_Message = createNewParamLableEx(640, 45,_SettingTool_GPRSAntennaCut_Message);
    var LabelReboot_Message = createNewParamLableEx(640, 75,_SettingTool_Reboot_Message);
    var LabelCrashAlarm_Message = createNewParamLableEx(640, 105,_SettingTool_CrashAlarm_Message);
    var LabelDistanceTracing_Message = createNewParamLableEx(640, 135,_TAResources_DistanceInterval);
    var LabelDemandInfoNow_Message = createNewParamLableEx(640, 165,_SettingTool_DemandInfoNow_Message);
    var LabelIntervalTracting_Message = createNewParamLableEx(640, 195,_TAResources_TimeInterval);
    var LabelTowAlarm_Message = createNewParamLableEx(640, 225,_AlarmResource_TowAlarm);

    // 拍照事件tab

    // var Photosm = new Ext.grid.CheckboxSelectionModel();
    // var Photocm = new Ext.grid.ColumnModel([
    // // new Ext.grid.RowNumberer(),// 自动行号
    // Photosm,// 添加的地方
    // {
    // header : '事件',
    // dataIndex : 'val',
    // width : 200
    // }
    //
    // ]);
    var PhotoStore = createEventCodeStoreEx(EnumAuthType.Photo, false);
    var PhotoCheckbox = new Ext.grid.CheckColumn({
        // header : 'flag',
        dataIndex: 'choosed',
        width: 60
    });
    var Photocm = new Ext.grid.ColumnModel([{
        header: _SettingTool_Event,
        width: 250,
        // sortable : true,
        dataIndex: 'val'

    }, PhotoCheckbox]);

    function addE01Command(read, mt88param) {
        var i = 0;
        var mt88cmd = EnumMT88Command.SetRead_EEP_Ext;
        var gvvtcommand = EnumGPRSCommand.NotSupportThisCommand;
        var gvvtparam = "";
        var gbcommand = "";
        var gbparam = 0;
        if (read) {
            mt88param = "01" + mt88param;
        }
        else
            mt88param = "00" + mt88param;
        alert(mt88param);
        if (Ext.isDefined(sssid)) {
            var index = devicestore.find('sssid', sssid);
            if (index != -1) {
                var record = devicestore.getAt(index);
                record.set('process', _TrackerMain_Sending);
                addOneTCPCommand(sssid, gvvtcommand, gvvtparam, mt88cmd, mt88param, gbcommand, gbparam);
            }
        }
        else {
            devicestore.each(function(record) {
                if (record.get('choosed')) {
                    var sssid = record.get('sssid');
                    if (sssid != "") {
                        record.set('process', _TrackerMain_Sending);
                        addOneTCPCommand(sssid, gvvtcommand, gvvtparam, mt88cmd, mt88param, gbcommand, gbparam);
                    }
                }
            });
        }
    };
    var validStr = "";

    //验证所有参数是否合法
    function validAllStr() {
    }
    
    //验证短信追踪参数是否合法
    function validSMSTrackingStr() {
        if (txtPassword.getValue().length != 4) {
            
            return false;
        }
    }

    function getWriteSMSTrackingStr() {
        var r = getHexE01WriteString(EnumE01Offset.TrackerPassword,(StringToASCHex(txtPassword.getValue() + '')))
		    + getHexE01WriteString(EnumE01Offset.SMSTrackInterval,(UInt16ToBigEndWORDStringNoComm(txtTimeInterval.getValue())))
		    + getHexE01WriteString(EnumE01Offset.SMSTrackTimes,(UInt16ToBigEndWORDStringNoComm(txtTrackingCount.getValue())))
		    + getHexE01WriteString(EnumE01Offset.TrackingNumber,padRight(StringToASCHex(txtTrackingNumber.getValue() + ''),'0',32));
        return r;
    }

    
    function getWriteGPRSTrackingStr() {
        var r = getHexE01WriteString(EnumE01Offset.GPRSConnectWay, UInt16ToBigEndWORDStringNoComm(cmbGPRSConnectModel.getValue()))
				+ getHexE01WriteString(EnumE01Offset.TrackInterval, UInt16ToBigEndWORDStringNoComm(txtGPRSInterval.getValue()))
				+ getHexE01WriteString(EnumE01Offset.EngineOffInterval, UInt16ToBigEndWORDStringNoComm(txtEngineClosedUploadInterval.getValue()))
				+ getHexE01WriteString(EnumE01Offset.EngineCheck, UInt8ToByteString(Bool2Int(!chkIgnitionOff.getValue())))
				+ getHexE01WriteString(EnumE01Offset.TrackTimes, UInt16ToBigEndWORDStringNoComm(txtGPRSTrackingCount.getValue()))
				+ getHexE01WriteString(EnumE01Offset.IP1, padRight(StringToASCHex(txtIP.getValue()), '0', 64))
				+ getHexE01WriteString(EnumE01Offset.Port1, padRight(StringToASCHex(txtPort.getValue()), '0', 10))
				+ getHexE01WriteString(EnumE01Offset.IP2, padRight(StringToASCHex(txtBackupIP.getValue()), '0', 64))
				+ getHexE01WriteString(EnumE01Offset.Port2, padRight(StringToASCHex(txtBackupPort.getValue()), '0', 10))
				+ getHexE01WriteString(EnumE01Offset.APN, padRight(StringToASCHex(txtAPN.getValue()), '0', 64))
				+ getHexE01WriteString(EnumE01Offset.APNUserName, padRight(StringToASCHex(txtAPNUserName.getValue()), '0', 64))
				+ getHexE01WriteString(EnumE01Offset.APNPassword, padRight(StringToASCHex(txtAPNPassword.getValue()), '0', 64));
				//+ getHexE01WriteString(EnumE01Offset.TrackerID,padRight(StringToASCHex(txtDeviceNumber.getValue()), '0', 64));
        return r;
    }

    
    function getWriteGPRSTracking1Str() {
        var r = getHexE01WriteString(EnumE01Offset.GPRSAuth, getAuthEx(GPRSStore, "choosed", false));
        return r;
    }

    function getWriteMainStr() {
        var r = getHexE01WriteString(EnumE01Offset.ProtocolType, UInt8ToByteString(cmbProtocolType.getValue()))
                +getHexE01WriteString(EnumE01Offset.SMSTimeZone,UInt16ToBigEndWORDStringNoComm(txtTimeZone.getValue()))
				+ getHexE01WriteString(EnumE01Offset.GPRSTimeZone,UInt16ToBigEndWORDStringNoComm(txtGPRSZone.getValue()))
				+ getHexE01WriteString(EnumE01Offset.DistanceInterval,UInt16ToBigEndWORDStringNoComm(txtDistanceTractingInterval.getValue()))
				+ getHexE01WriteString(EnumE01Offset.Turn,UInt16ToBigEndWORDStringNoComm(txtAngleTurn.getValue()))
				+ getHexE01WriteString(EnumE01Offset.MaxSpeed,UInt16ToBigEndWORDStringNoComm(txtOverSpeedAlarm.getValue()))
				+ getHexE01WriteString(EnumE01Offset.ExternalPowerLow,UInt16ToBigEndWORDStringNoComm(parseInt(parseFloat(txtExternalPowerLowValue.getValue())*10)))
				+ getHexE01WriteString(EnumE01Offset.Heartbeat,UInt16ToBigEndWORDStringNoComm(txtHeartbeatPacketInterval.getValue()))
				+ getHexE01WriteString(EnumE01Offset.LogInteravl,UInt16ToBigEndWORDStringNoComm(txtRecorderInterval.getValue()))
				+ getHexE01WriteString(EnumE01Offset.Tow, UInt16ToBigEndWORDStringNoComm(txtTowAlarmShakeTime.getValue()))
				+ getHexE01WriteString(EnumE01Offset.AccInputGPSleep, UInt8ToByteString(cmbSleepModelEx.getValue()))
				+ getHexE01WriteString(EnumE01Offset.LEDOff, UInt8ToByteString(Bool2Int(chkLEDOff.getValue())))
				+ getHexE01WriteString(EnumE01Offset.BuzzerOff, UInt8ToByteString(Bool2Int(chkBuzzerOff.getValue())));
        return r;
    }

    function getWriteGeoFenceStr() {
        var stringGEO1 = UInt32ToDWORDStringNoComm(parseInt(txtLng1.getValue() * 1000000)) + UInt32ToDWORDStringNoComm(parseInt(txtLat1.getValue() * 1000000))
                        + UInt32ToDWORDStringNoComm(txtRadius1.getValue())+ UInt8ToByteString(Bool2Int(checkboxEnterGEO1.getValue())+ Bool2Int(checkboxExitGEO1.getValue()) * 2)+ "000000";
        var stringGEO2 = UInt32ToDWORDStringNoComm(parseInt(txtLng2.getValue() * 1000000)) + UInt32ToDWORDStringNoComm(parseInt(txtLat2.getValue() * 1000000))
                        + UInt32ToDWORDStringNoComm(txtRadius2.getValue())+ UInt8ToByteString(Bool2Int(checkboxEnterGEO2.getValue())+ Bool2Int(checkboxExitGEO2.getValue()) * 2)+ "000000";
        var stringGEO3 = UInt32ToDWORDStringNoComm(parseInt(txtLng3.getValue() * 1000000)) + UInt32ToDWORDStringNoComm(parseInt(txtLat3.getValue() * 1000000))
                        + UInt32ToDWORDStringNoComm(txtRadius3.getValue())+ UInt8ToByteString(Bool2Int(checkboxEnterGEO3.getValue())+ Bool2Int(checkboxExitGEO3.getValue()) * 2)+ "000000";
        var stringGEO4 = UInt32ToDWORDStringNoComm(parseInt(txtLng4.getValue() * 1000000)) + UInt32ToDWORDStringNoComm(parseInt(txtLat4.getValue() * 1000000))
						+ UInt32ToDWORDStringNoComm(txtRadius4.getValue())+ UInt8ToByteString(Bool2Int(checkboxEnterGEO4.getValue())+ Bool2Int(checkboxExitGEO4.getValue()) * 2)+ "000000";
        var stringGEO5 = UInt32ToDWORDStringNoComm(parseInt(txtLng5.getValue() * 1000000)) + UInt32ToDWORDStringNoComm(parseInt(txtLat5.getValue() * 1000000))
						+ UInt32ToDWORDStringNoComm(txtRadius5.getValue())+ UInt8ToByteString(Bool2Int(checkboxEnterGEO5.getValue())+ Bool2Int(checkboxExitGEO5.getValue()) * 2)+ "000000";
        var stringGEO6 = UInt32ToDWORDStringNoComm(parseInt(txtLng6.getValue() * 1000000)) + UInt32ToDWORDStringNoComm(parseInt(txtLat6.getValue() * 1000000))
						+ UInt32ToDWORDStringNoComm(txtRadius6.getValue())+ UInt8ToByteString(Bool2Int(checkboxEnterGEO6.getValue())+ Bool2Int(checkboxExitGEO6.getValue()) * 2)+ "000000";
        var stringGEO7 = UInt32ToDWORDStringNoComm(parseInt(txtLng7.getValue() * 1000000)) + UInt32ToDWORDStringNoComm(parseInt(txtLat7.getValue() * 1000000))
						+ UInt32ToDWORDStringNoComm(txtRadius7.getValue())+ UInt8ToByteString(Bool2Int(checkboxEnterGEO7.getValue())+ Bool2Int(checkboxExitGEO7.getValue()) * 2)+ "000000";
        var stringGEO8 = UInt32ToDWORDStringNoComm(parseInt(txtLng8.getValue() * 1000000)) + UInt32ToDWORDStringNoComm(parseInt(txtLat8.getValue() * 1000000))
                        + UInt32ToDWORDStringNoComm(txtRadius8.getValue())+ UInt8ToByteString(Bool2Int(checkboxEnterGEO8.getValue())+ Bool2Int(checkboxExitGEO8.getValue()) * 2)+ "000000";

        r = getHexE01WriteString(EnumE01Offset.GeoFence, stringGEO1
												+ stringGEO2 + stringGEO3
												+ stringGEO4 + stringGEO5
												+ stringGEO6 + stringGEO7
												+ stringGEO8);
        return r;
    }
  
    function getWriteSMSAuthStr() {
        var r = getHexE01WriteString(EnumE01Offset.SMSAuth,padRight(StringToASCHex(txtAuthNumber1.getValue()), '0', 32)	+ getAuthEx(SMSStore, "choosed",false)
				+ padRight(StringToASCHex(txtAuthNumber2.getValue()), '0', 32) + getAuthEx(SMSStore, "choosed1", false)
				+ padRight(StringToASCHex(txtAuthNumber3.getValue()), '0', 32) + getAuthEx(SMSStore, "choosed2", false)
				+ padRight(StringToASCHex(txtListenerNumber1.getValue() + ''), '0', 32) + "00000000000000000001000000000000"
				+ padRight(StringToASCHex(txtListenerNumber2.getValue() + ''), '0', 32) + "00000000000000000001000000000000");
        return r;
    }

    
    function getWriteEventHeaderStr() {
        var r = getHexE01WriteString("0340",padRight(StringToASCHex(txtInput1Activate_Message.getValue()),'0',32))
			+ getHexE01WriteString("0350",padRight(StringToASCHex(txtInput2Activate_Message.getValue()),'0',32))
			+ getHexE01WriteString("0360",padRight(StringToASCHex(txtInput3Activate_Message.getValue()),'0',32))
			+ getHexE01WriteString("0370",padRight(StringToASCHex(txtInput4Activate_Message.getValue()),'0',32))
			+ getHexE01WriteString("0380",padRight(StringToASCHex(txtInput5Activate_Message.getValue()),'0',32))
			+ getHexE01WriteString("03C0",padRight(StringToASCHex(txtInput1NotActivate_Message.getValue()),'0',32))
			+ getHexE01WriteString("03D0",padRight(StringToASCHex(txtInput2NotActivate_Message.getValue()),'0',32))
			+ getHexE01WriteString("03E0",padRight(StringToASCHex(txtInput3NotActivate_Message.getValue()),'0',32))
			+ getHexE01WriteString("03F0",padRight(StringToASCHex(txtInput4NotActivate_Message.getValue()),'0',32))
			+ getHexE01WriteString("0400",padRight(StringToASCHex(txtInput5NotActivate_Message.getValue()),'0',32))
			+ getHexE01WriteString("0440",padRight(StringToASCHex(txtBuiltinLowVoltage_Message.getValue()),'0',32))
			+ getHexE01WriteString("0450",padRight(StringToASCHex(txtOutlayLowVoltage_Message.getValue()),'0',32))
			+ getHexE01WriteString("0460",padRight(StringToASCHex(txtOverSpeedAlarm_Message.getValue()),'0',32))
			+ getHexE01WriteString("0470",padRight(StringToASCHex(txtEnterGEO_Message.getValue()),'0',32))
			+ getHexE01WriteString("0480",padRight(StringToASCHex(txtExitGEO_Message.getValue()),'0',32))
			+ getHexE01WriteString("0490",padRight(StringToASCHex(txtOutlayPowerOn_Message.getValue()),'0',32))
			+ getHexE01WriteString("04A0",padRight(StringToASCHex(txtOutlayPowerOff_Message.getValue()),'0',32))
			+ getHexE01WriteString("04B0",padRight(StringToASCHex(txtNotFixGPRS_Message.getValue()),'0',32))
			+ getHexE01WriteString("04C0",padRight(StringToASCHex(txtFixGPRS_Message.getValue()),'0',32))
			+ getHexE01WriteString("04D0",padRight(StringToASCHex(txtEnterSleep_Message.getValue()),'0',32))
			+ getHexE01WriteString("04E0",padRight(StringToASCHex(txtExitSleep_Message.getValue()),'0',32))
			+ getHexE01WriteString("04F0",padRight(StringToASCHex(txtGPRSAntennaCut_Message.getValue()),'0',32))
			+ getHexE01WriteString("0500",padRight(StringToASCHex(txtReboot_Message.getValue()),'0',32))
			+ getHexE01WriteString("0510",padRight(StringToASCHex(txtCrashAlarm_Message.getValue()),'0',32))
			+ getHexE01WriteString("0540",padRight(StringToASCHex(txtDistanceTracing_Message.getValue()),'0',32))
			+ getHexE01WriteString("0550",padRight(StringToASCHex(txtDemandInfoNow_Message.getValue()),'0',32))
			+ getHexE01WriteString("0560",padRight(StringToASCHex(txtIntervalTracting_Message.getValue()),'0',32))
			+ getHexE01WriteString("0570",padRight(StringToASCHex(txtTowAlarm_Message.getValue()),'0',32));
        return r;
    }

    function getWritePhotoAuthStr() {
        var r = getHexE01WriteString(EnumE01Offset.PhotoAuth, getAuthEx(PhotoStore, "choosed", true));
        return r;
    }

    var toolabr = new Ext.Toolbar({
        width: 800,
        height: 30,
        items: ['-', {
            iconCls: 'readAllParameter',
            tooltip: '<b>' + _SettingTool_ReadAllParams
							+ '</b><hr>' + _SettingTool_ReadAllParameterSetting
							+ '',
            xtype: 'button',
            handler: function() {
                var r = getReadSMSTrackingStr()
								+ getReadGPRSTrackingStr()
								+ getReadGPRSTracking1Str()
								+ getReadMainStr()
								+ getReadEventHeaderStr()
								+ getReadSMSAuthStr()
								+ getReadPhotoAuthStr()
								+ getReadGeoFenceStr();
                addE01Command(true, r);
                //AnalyzSplit();
            },
            text: _SettingTool_ReadAllParams

        }, '-', {
            iconCls: 'writeAllParameter',
            tooltip: '<b>' + _SettingTool_WriteAllParams
							+ '</b><hr>'
							+ _SettingTool_WriteAllParameterSetting + '',
            xtype: 'button',
            handler: function() {
                var r = getWriteSMSTrackingStr()
						+ getWriteGPRSTracking1Str()
						+ getWriteMainStr()
						+ getWriteGeoFenceStr()
						+ getWriteSMSAuthStr()
						+ getWriteEventHeaderStr()
						+ getWritePhotoAuthStr();
                        //+getWriteGPRSTrackingStr(); 暂时去掉防止设备直接下线
                addE01Command(false, r);
            },
            text: _SettingTool_WriteAllParams
        }, '-']
    });

    // ***************************************************TabPanel*********************************
    // TabPanel
    var tabs = new Ext.TabPanel({
        activeTab: 0,
        frame: true,
        // height : 400,
        // width:800,
        // autoHeight : true,
        // layout:'fit',
        defaults: {
            bodyStyle: 'padding:10px',
            autoScroll: true,
            height: 310,
            width: 780
        },
        items: [{
            title: _SettingTool_Tracing_Message,
            iconCls: 'tracingmessage',
            layout: 'absolute',
            // height : 200,

            // defaultType : 'textfield',
            items: [txtPassword, txtTrackingCount, txtTrackingNumber,
					txtTimeInterval, lblPasssword, lblTrackingCount,
					lblNumber, lblTimeInterval, {
					    layout: 'table',
					    baseCls: 'x-plain',
					    bodyStyle: 'padding:20px',
					    x: 170,
					    y: 130,
					    defaults: {
					        width: 75
					    },
					    items: [{
					        xtype: 'button',
					        text: _SettingTool_Read,
					        handler: function() {
					            addE01Command(true, getReadSMSTrackingStr());
					            //AnalyzSplit("030000023131032000020b00032200020b00031000020b00");
					        },
					        style: {
					            marginRight: '10px'
					        }
					    }, {
					        xtype: 'button',
					        handler: function() {
					            addE01Command(false, getWriteSMSTrackingStr());
					        },
					        text: _SettingTool_Write
                    }]
            }]
        }, {
            title: _SettingTool_GPRSTracing,
            iconCls: 'gprsTracing',
            layout: 'absolute',
            // height : 500,
            items: [txtEngineClosedUploadInterval, txtGPRSInterval,
					txtGPRSTrackingCount, txtIP, txtPort, txtBackupIP,
					txtBackupPort, txtAPN, txtAPNUserName, txtAPNPassword,
					txtDeviceNumber, lblGPRSTrackingInterval,
					lblEngineClosedUploadInterval, lblGPRSTrackingCount,
					lblIP, lblPort, lblBackupIP, lblBackupPort,
					lblAPN, lblAPNUserName, lblAPNPassword,
					lblDeviceNumber, lblGPRSConnectModel,
					cmbGPRSConnectModel,
					createNewParamLableEx(262, 45, "*10" + _TrackerMain_S),
					createNewParamLableEx(262, 75, "*10" + _TrackerMain_S),
					createNewParamLableEx(330, 75, _TrackerMain_Cancel),chkIgnitionOff, {
					    xtype: 'button',
					    x: 165,
					    y: 370,
					    text: _SettingTool_Read,
					    handler: function() {
					        addE01Command(true, getReadGPRSTrackingStr());
					    },
					    width: 75
					}, {
					    xtype: 'button',
					    x: 245,
					    y: 370,
					    text: _SettingTool_Write,
					    handler: function() {
					        addE01Command(false, getWriteGPRSTrackingStr());
					    },
					    width: 75

					}, new Ext.grid.GridPanel({
					    height: 350,
					    width: 350,
					    x: 400,
					    y: 10,
					    id: 'GPRS',
					    store: GPRSStore,
					    cm: GPRScm,
					    plugins: GPSRCheckbox

					}), {
					    xtype: 'button',
					    width: 75,
					    text: _SettingTool_Read,
					    handler: function() {
					        addE01Command(true, getReadGPRSTracking1Str());
					        // alert(stringGPRSTractingRead1);
					        //AnalyzSplit("03300008000000060000000F");

					    },
					    x: 400,
					    y: 370
					}, {
					    xtype: 'button',
					    width: 75,
					    text: _SettingTool_Write,
					    handler: function() {
					        addE01Command(false, getWriteGPRSTracking1Str());
					    },
					    x: 480,
					    y: 370
}]
        }, {
            xtype: 'panel',
            iconCls: 'mainParameter',
            title: _SettingTool_MainParameter,
            layout: 'absolute',
            // defaultType : 'textfield',
            items: [lblEventReliableTransMode, txtTimeZone, txtGPRSZone,
					txtDistanceTractingInterval, txtAngleTurn,
					txtOverSpeedAlarm, txtExternalPowerLowValue,
					txtHeartbeatPacketInterval, txtRecorderInterval,
					txtTowAlarmShakeTime, lblTimeZone, lblGPRSZone,
					lblDistanceTractingInterval, lblAngleTurn,
					lblOverSpeedAlarm, lblExternalPowerLowValue,
					lblHeartbeatPacketInterval, lblRecorderInterval,
					lblTowAlarmShakeTime, lblSleepModel, lblLED,
					lblFMQ, cmbProtocolType, cmbSleepModelEx,
					createNewParamLableEx(262, 45, "*" + _TrackerMain_M),
					createNewParamLableEx(262, 75, "*" + _TrackerMain_M),
					createNewParamLableEx(262, 105, "*" + _Turn_Meters),
					createNewParamLableEx(262, 135, "*" + _TrackerMain_Degree),
					createNewParamLableEx(262, 165, "*" + _SettingTool_KM),
					createNewParamLableEx(262, 195, _SettingTool_Volt),
					createNewParamLableEx(262, 225, _TrackerMain_M),
					createNewParamLableEx(262, 255, _TrackerMain_S),
					createNewParamLableEx(262, 285, _TrackerMain_S), {
					    xtype: 'button',
					    x: 495,
					    y: 100,
					    text: _SettingTool_Read,
					    handler: function() {
					        addE01Command(true, getReadMainStr());
					        //AnalyzSplit("028000026f0002A90002de00028C00024d01028E0002bc01029000022b02029400029a02029600020903029800027803029A0002e703");
					    },
					    width: 75
					}, {
					    xtype: 'button',
					    x: 580,
					    y: 100,
					    text: _SettingTool_Write,
					    handler: function() {
					        // Gprs事件可靠传输方式和休眠模式没有

					        addE01Command(false, getWriteMainStr());

					    },
					    width: 75
					}, chkLEDOff,chkBuzzerOff]

        }, {
            title: _TAResources_SettingFence,
            iconCls: 'electronicfence',
            layout: 'absolute',
            // height:350
            items: [txtLng1, txtLng2, txtLng3, txtLng4, txtLng5, txtLng6,
					txtLng7, txtLng8, txtRadius1, txtRadius2, txtRadius3,
					txtRadius4, txtRadius5, txtRadius6, txtRadius7, txtRadius8,
					txtLat1, txtLat2, txtLat3, txtLat4, txtLat5, txtLat6,
					txtLat7, txtLat8, LabelDZWL, LabelLat, LabelLng, LabelRa,
					LabelLat1, LabelLat2, LabelLat3, LabelLat4, LabelLat5,
					LabelLat6, LabelLat7, LabelLat8, LabelEnterGEO,
					LabelExitGEO, checkboxEnterGEO1, checkboxEnterGEO2,
					checkboxEnterGEO3, checkboxEnterGEO4, checkboxEnterGEO5,
					checkboxEnterGEO6, checkboxEnterGEO7, checkboxEnterGEO8,
					checkboxExitGEO1, checkboxExitGEO2, checkboxExitGEO3,
					checkboxExitGEO4, checkboxExitGEO5, checkboxExitGEO6,
					checkboxExitGEO7, checkboxExitGEO8, {
					    layout: 'table',
					    baseCls: 'x-plain',
					    bodyStyle: 'padding:20px',
					    x: 280,
					    y: 260,

					    defaults: {
					        width: 75
					    },
					    items: [{
					        xtype: 'button',
					        text: _SettingTool_Read,
					        handler: function() {
					            addE01Command(true, getReadGeoFenceStr());
					        },
					        style: {
					            marginRight: '10px'
					        }

					    }, {
					        xtype: 'button',
					        handler: function() {
					            addE01Command(false, getWriteGeoFenceStr());

					        },
					        text: _SettingTool_Write

}]

}]
        }, {
            title: _SettingTool_AccreditNumber,
            iconCls: 'accreditNumber',
            layout: 'absolute',

            items: [lblAuthNumber, LabelListenerNumber,
					txtAuthNumber1, txtAuthNumber2, txtAuthNumber3,
					txtListenerNumber1, txtListenerNumber2, {
					    xtype: 'button',
					    x: 610,
					    width: 75,
					    y: 80,
					    handler: function() {
					        addE01Command(true, getReadSMSAuthStr());
					    },
					    text: _SettingTool_Read
					}, {
					    xtype: 'button',
					    x: 690,
					    width: 75,
					    y: 80,
					    handler: function() {
					        addE01Command(false, getWriteSMSAuthStr());
					    },
					    text: _SettingTool_Write
					}, new Ext.grid.GridPanel({
					    x: 5,
					    y: 40,
					    width: 570,
					    height: 350,
					    cm: SMScm,
					    plugins: [SMSCheckbox1, SMSCheckbox2, SMSCheckbox3],
					    store: SMSStore
					})]

        }, {
            title: _SettingTool_MessageEventChar,
            iconCls: 'messageEventChar',
            layout: 'absolute',
            autoScroll: true,
            items: [LabelInput1Activate_Message, LabelInput2Activate_Message,
					LabelInput3Activate_Message, LabelInput4Activate_Message,
					LabelInput5Activate_Message,
					LabelInput1NotActivate_Message,
					LabelInput2NotActivate_Message,
					LabelInput3NotActivate_Message,
					LabelInput4NotActivate_Message,
					LabelInput5NotActivate_Message, txtInput1Activate_Message,
					LabelBuiltinLowVoltage_Message, txtInput2Activate_Message,
					txtExitSleep_Message, LabelExitSleep_Message,
					LabelOutlayLowVoltage_Message, lblOverSpeedAlarm_Message,
					LabelEnterGEO_Message, LabelExitGEO_Message,
					LabelOutlayPowerOn_Message, LabelOutlayPowerOff_Message,
					LabelNotFixGPRS_Message, LabelFixGPRS_Message,
					LabelEnterSleep_Message, LabelGPRSAntennaCut_Message,
					LabelReboot_Message, LabelCrashAlarm_Message,
					LabelDistanceTracing_Message, LabelDemandInfoNow_Message,
					LabelIntervalTracting_Message, LabelTowAlarm_Message,
					txtInput2Activate_Message, txtInput3Activate_Message,
					txtInput4Activate_Message, txtInput5Activate_Message,
					txtInput1NotActivate_Message, txtInput2NotActivate_Message,
					txtInput3NotActivate_Message, txtInput4NotActivate_Message,
					txtInput5NotActivate_Message, txtOutlayLowVoltage_Message,
					txtOverSpeedAlarm_Message, txtEnterGEO_Message,
					txtExitGEO_Message, txtOutlayPowerOn_Message,
					txtOutlayPowerOff_Message, txtNotFixGPRS_Message,
					txtFixGPRS_Message, txtEnterSleep_Message,
					txtGPRSAntennaCut_Message, txtReboot_Message,
					txtCrashAlarm_Message, txtDistanceTracing_Message,
					txtDemandInfoNow_Message, txtIntervalTracting_Message,
					txtTowAlarm_Message, txtBuiltinLowVoltage_Message, {
					    xtype: 'button',
					    text: _SettingTool_Read,
					    handler: function() {
					        addE01Command(true, getReadEventHeaderStr());
					    },
					    width: 75,
					    x: 5,
					    y: 320
					}, {
					    xtype: 'button',
					    text: _SettingTool_Write,
					    handler: function() {

					        addE01Command(false, getWriteEventHeaderStr());
					    },
					    width: 75,
					    x: 85,
					    y: 320
}]
        }, {
            title: _SettingTool_PhotoEvent,
            iconCls: 'PhotoEvent',
            layout: 'absolute',

            items: [new Ext.grid.GridPanel({
                x: 50,
                y: 5,
                height: 350,
                width: 350,
                // sm : Photosm,
                cm: Photocm,
                plugins: PhotoCheckbox,
                store: PhotoStore

            }), {
                xtype: 'button',
                width: 75,
                x: 250,
                y: 370,
                handler: function() {
                    addE01Command(true, getReadPhotoAuthStr());
                    //AnalyzSplit("075000080020000000000009");
                },
                text: _SettingTool_Read
            }, {
                width: 75,
                xtype: 'button',
                x: 330,
                y: 370,
                handler: function() {

                    addE01Command(false, getWritePhotoAuthStr());

                },
                text: _SettingTool_Write
                }]
            }]

            });

        // tabs.render(document.body);
        // 控件生成
        // 创建下拉列表
        function createComboBoxForCommandEx(x, y, store, valueField, displayField, width,selectFn) {
            var combo = new Ext.form.ComboBox({
                editable: false,
                // hideLabel : label == "" ? true : false,
                // labelStyle : 'padding-left:10px;text-align:left',
                // fieldLabel : label,
                store: store,
                autoSelect: true,
                shadow: true,
                x: x,
                y: y,
                valueField: valueField,
                displayField: displayField,
                // typeAhead : typeAhead,
                mode: 'local',
                forceSelection: true, // 单选
                triggerAction: 'all',
                // emptyText : '',
                // selectOnFocus : selectOnFocus,
                width: width
                // tpl : tpl

            });
            if (selectFn != null || selectFn != undefined)
                combo.addListener('select', selectFn);
            return combo;
        }


        function createNewMultiParamCmbFieldEx(pstore, labelcap, etext) {
            var pcmbfield = new Ext.ux.form.CheckboxCombo({
                // editable: false,
                labelStyle: 'padding-top:6px;padding-left:10px;text-align:left',
                fieldLabel: labelcap,
                store: pstore,
                valueField: 'valueid',
                displayField: 'val',
                // typeAhead: false,
                mode: 'local',
                // forceSelection: true,
                // triggerAction: 'all',
                // emptyText:_TrackerMain_SelectACommand,
                // selectOnFocus: true,
                width: 150
            });
            if (etext == null)
                pcmbfield.emptyText = _TrackerMain_SelectACommand;
            else
                pcmbfield.emptyText = etext;
            return pcmbfield;
        }

        function createNewParamNumberFieldEx(x, y, readOnly,maxvalue,minvalue, allowdecimals,decimalprecision, maxlength, id) {
            var config = {
                // fieldLabel: labelcap,
                maxLength: maxlength,
                x: x,
                y: y,
                labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
                width: 120,
                readOnly: readOnly,
                allowBlank: false,
                allowDecimals: Ext.isDefined(allowdecimals) ? allowdecimals : false,
                decimalPrecision: Ext.isDefined(decimalprecision) ? decimalprecision : 0
                
            };
            if (Ext.isDefined(id))
                config.id = id;
            if (Ext.isDefined(maxvalue))
                config.maxValue = maxvalue;
            if (Ext.isDefined(minvalue))
                config.minValue = minvalue;
            var pnumberfield = new Ext.form.NumberField(config);
            if (readOnly == true) {
                pnumberfield.addClass("textfield_readOnly");
            }
            return pnumberfield;
        }

        function createNewParamTextFieldEx(x, y, readOnly, maxlength, id, name) {
            var config = {
                // fieldLabel: labelcap,
                maxLength: maxlength,
                labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
                width: 120,
                x: x,
                y: y,
                value: "", // 这个默认值
                readOnly: readOnly
            };
            if (Ext.isDefined(id))
                config.id = id;
            if (Ext.isDefined(name))
                config.name = name;
            var pfield = new Ext.form.TextField(config);
            if (maxlength)
                pfield.maxLength = maxlength;
            if (readOnly == true) {
                pfield.addClass("textfield_readOnly");
            }
            return pfield;
        }
        // 文本域
        function createNewParamTextAreaEx(labelcap, maxlength, readOnly, id, name) {
            var config = {
                fieldLabel: labelcap,
                maxLength: maxlength,
                labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
                height: 100,
                width: 200,
                value: "",
                readOnly: readOnly
            };
            if (Ext.isDefined(id))
                config.id = id;
            if (Ext.isDefined(name))
                config.name = name;
            var pfield = new Ext.form.TextArea(config);
            if (maxlength)
                pfield.maxLength = maxlength;

            return pfield;
        }

        function createNewParamDateEx(labelcap, readOnly, id, name, format) {
            var config = {
                fieldLabel: labelcap,
                labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
                height: 100,
                width: 150,
                value: "",
                readOnly: readOnly,
                format: 'm-d'
            };
            if (Ext.isDefined(id))
                config.id = id;
            if (Ext.isDefined(name))
                config.name = name;
            if (Ext.isDefined(format))
                config.format = format;
            var pfield = new Ext.form.DateField(config);
            return pfield;
        }

        function createNewParamTimeEx(labelcap, readOnly, id, name, format) {
            var config = {
                fieldLabel: labelcap,
                labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
                height: 100,
                width: 150,
                value: "",
                readOnly: readOnly,
                format: 'H:i'
            };
            if (Ext.isDefined(id))
                config.id = id;
            if (Ext.isDefined(name))
                config.name = name;
            if (Ext.isDefined(format))
                config.format = format;
            var pfield = new Ext.form.TimeField(config);
            return pfield;
        }
        // label
        function createNewParamLableEx(x, y, text) {
            var config = {
                x: x,
                y: y,
                text: text,
                // labelStyle :'label',
                autoWidth: true
            }
            var r = new Ext.form.Label(config);
            return r;
        }
        function createNewParamCheckbox(x, y) {
            var config = {
                x: x,
                y: y
            }
            var r = new Ext.form.Checkbox(config);
            return r;
        }
        // 枚举类型
        var EnumParamFieldType = {
            TextField: 0,
            NumberField: 1,
            ComboBoxField: 2,
            MultiComboBoxField: 3,
            TextArea: 4,
            Date: 5,
            Time: 6,
            lable: 7
        }

        function createNewParamAndShowEx(paramfieldtype, captext, maxlen, unittext, cmbstore, name, id) {
            var r;
            if (unittext.length == 0)
                unittext = " "; // give a space if text is empty
            var lblunit = createNewParamUnitLabel(unittext);
            if (paramfieldtype == EnumParamFieldType.TextField)
                r = createNewParamTextFieldEx(captext, maxlen, false, null, name);
            else if (paramfieldtype == EnumParamFieldType.NumberField)
                r = createNewParamNumberFieldEx(captext, maxlen);
            else if (paramfieldtype == EnumParamFieldType.ComboBoxField) {
                r = createNewParamCmbField(cmbstore, captext);
                r.setValue(cmbstore.getAt(0).get(r.valueField));
            } else if (paramfieldtype == EnumParamFieldType.MultiComboBoxField) {
                r = createNewMultiParamCmbFieldEx(cmbstore, captext);
            } else if (paramfieldtype == EnumParamFieldType.TextArea) {
                r = createNewParamTextAreaEx(captext, maxlen);
            } else if (paramfieldtype == EnumParamFieldType.Date) {
                r = createNewParamDateEx(captext, false, id);
            } else if (paramfieldtype == EnumParamFieldType.Time) {
                r = createNewParamTimeEx(captext, false, id);
            }
            if (!Ext.isEmpty(name))
                r.name = name;

            return r;
        }
            // 创建例子
            // var txtPassword = createNewParamAndShowEx
            // (EnumParamFieldType.ComboBoxField,_TrackerMain_Password,4,_TrackerMain_Seconds,store);

            // var panel = new Ext.Panel({
            // items:[txtpassword,
            // txtUserName,
            // txtPhoneNumber]

            // });

            // var command = "AA"+ txtUsername.getValue() +"," + txtPassword.getValue()

            

            // 动态生成 报警授权,包括3中短信,GPRS, 照相 authType 为EnumAuthType枚举
        function getEventCodeNamesEx(authType, isSMSHeader) { // 下面的字符变量可以在字符变量js中找到
            var authcodearray = [];
            authcodearray.push(['1', _AlarmResource_SOSButton_Pressed_Input1_Active,false, false, false]);
            authcodearray.push(['2', _AlarmResource_ButtonB_Pressed_Input2_Active,false, false, false]);
            authcodearray.push(['3', _AlarmResource_ButtonC_Pressed_Input3_Active,false, false, false]);
            authcodearray.push(['4', _AlarmResource_Input4_Active, false, false, false]);
            authcodearray.push(['5', _AlarmResource_Input5_Active, false, false, false]);
            authcodearray.push(['9', _AlarmResource_SOSButton_Released_Input1_InActive,	false, false, false]);
            authcodearray.push(['10', _AlarmResource_ButtonB_Released_Input2_InActive,	false, false, false]);
            authcodearray.push(['11', _AlarmResource_ButtonC_Released_Input3_InActive,false, false, false]);
            authcodearray.push(['12', _AlarmResource_Input4_InActive, false, false,	false]);
            authcodearray.push(['13', _AlarmResource_Input5_InActive, false, false,	false]);
            if (authType != EnumAuthType.Photo) {
                authcodearray.push(['17', _AlarmResource_LowBattery, false, false,false]);
                authcodearray.push(['18', _AlarmResource_LowExternalPower, false,false, false]);
            }
            authcodearray.push(['19', _AlarmResource_OverSpeed, false, false, false]);
            authcodearray.push(['20', _AlarmResource_EnterGeofence, false, false, false]);
            authcodearray.push(['21', _AlarmResource_ExitGeofence, false, false, false]);
            authcodearray.push(['22', _AlarmResource_ExternalPowerOn, false, false,false]);
            if (authType != EnumAuthType.Photo) {
                authcodearray.push(['23', _AlarmResource_ExternalPowerOff, false,false, false]);
                authcodearray.push(['24', _AlarmResource_EnterGPSBlindAlarm, false,false, false]);
                authcodearray.push(['25', _AlarmResource_ExitGPSBlindAlarm, false,false, false]);
                authcodearray.push(['26', _AlarmResource_EnterSleep, false, false,false]);
                authcodearray.push(['27', _AlarmResource_ExitSleep, false, false, false]);
            }
            authcodearray.push(['28', _AlarmResource_GPSAntennaCut, false, false, false]);
            if (authType != EnumAuthType.Photo) {
                authcodearray.push(['29', _AlarmResource_TurnOnAlarm, false, false,false]);
            }
            authcodearray.push(['30', _AlarmResource_Impact, false]);
            if (authType == EnumAuthType.GPRS) {
                authcodearray.push(['31', _AlarmResource_HeartbeatReport, false, false,false]);
                authcodearray.push(['32', _AlarmResource_Veer_report, false, false,false]);
            }
            if (authType != EnumAuthType.Photo) {
                authcodearray.push(['33', _AlarmResource_DistanceIntervalReport, false,false, false]);
                // authcodearray.push(['34', _AlarmResource_CurrentLocationReport,
                // false]);
            }
            // if((authType == EnumAuthType.GPRS) || isSMSHeader )
            // authcodearray.push(['35', _AlarmResource_TimeIntervalReport,false]);
            authcodearray.push(['36', _AlarmResource_TowAlarm, false, false, false]);
            if (authType != EnumAuthType.SMS)
                authcodearray.push(['37', _AlarmResource_RFID, false, false, false]);
            if (typeof (showFuelDown) != 'undefined') {
                if (showFuelDown)
                    authcodearray.push(['54', _TrackerMain_FuelDown, false, false,false]);
            }
            if ((authType == EnumAuthType.SMS) && (!isSMSHeader)) {
                authcodearray.push(['65', _AlarmResource_SOSCall, false, false, false]);
                authcodearray.push(['66', _AlarmResource_Input2Call, false, false,false]);
                authcodearray.push(['67', _AlarmResource_Input3Call, false, false,false]);
                authcodearray.push(['68', _AlarmResource_Input4Call, false, false,false]);
                authcodearray.push(['69', _AlarmResource_Input5Call, false, false,false]);
                authcodearray.push(['70', _AlarmResource_RejectIncomingCall, false,false, false]);
                authcodearray.push(['71', _AlarmResource_ReportLocationCalling, false,false, false]);
                authcodearray.push(['72', _AlarmResource_AutoAnswerIncoming, false,false, false]);
                authcodearray.push(['73', _AlarmResource_Listenin, false, false, false]);
            }
            return authcodearray;
        }

        function createEventCodeStoreEx(authType, isSMSHeader) {
            var darray = getEventCodeNamesEx(authType, isSMSHeader);
            var sto = new Ext.data.ArrayStore({
                fields: ['valueid', 'val', {
                    name: 'choosed',
                    type: 'bool'
                }, {
                    name: 'choosed1',
                    type: 'bool'
                }, {
                    name: 'choosed2',
                    type: 'bool'
                }],
                    data: darray
                });
                return sto;
            }

        // checkcolum扩展类
        Ext.grid.CheckColumn = function(config) {
            Ext.apply(this, config);
            if (!this.id) {
                this.id = Ext.id();
            }
            this.renderer = this.renderer.createDelegate(this);
        };

        Ext.grid.CheckColumn.prototype = {
            init: function(grid) {
                this.grid = grid;
                this.grid.on('render', function() {
                    var view = this.grid.getView();
                    view.mainBody.on('mousedown', this.onMouseDown, this);
                }, this);
            },

            onMouseDown: function(e, t) {
                if (t.className && t.className.indexOf('x-grid3-cc-' + this.id) != -1) {
                    e.stopEvent();
                    var index = this.grid.getView().findRowIndex(t);
                    var record = this.grid.store.getAt(index);
                    record.set(this.dataIndex, !record.data[this.dataIndex]);
                }
            },

            renderer: function(v, p, record) {
                p.css += ' x-grid3-check-col-td';
                return '<div class="x-grid3-check-col' + (v ? '-on' : '')
		+ ' x-grid3-cc-' + this.id + '">&#160;</div>';
            }

        };

        // / 布尔类型转换为整型
        function Bool2Int(obj) {
            if (obj == true)
                return 1;
            else
                return 0;
        };

        this.AnalyzE01Data = function(readwrite, datastr) {
            if (readwrite == 1)
                AnalyzSplit(datastr);
            else if (readwrite == 0) {
                
            }

        };

        function AnalyzSplit(str) {
            var index = 0;
            // function ParamStruct{
            // this.Offset = null;
            // this.Len = 0;
            // this.Data = null;
            // }
            // var array = [];
            while (index < str.length) {
                var offset = str.substr(index, 4);
                index += 4;
                var lenstr = str.substr(index, 4);
                var len = parseInt(lenstr, 16);
                index += 4;
                var datastr = str.substr(index, len * 2);
                index += len * 2;
                /*
                * var pm = new ParamStruct(); pm.Offset = offset; pm.Len = len; pm.Data =
                * datastr; array.push(pm);
                */
                Analyer(offset, datastr);
            }
        };

        function Analyer(offset, e01data) {
            switch (offset) {
                // 短信追踪  
                case EnumE01Offset.TrackerPassword:
                    txtPassword.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.TrackingNumber:
                    txtTrackingNumber.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.SMSTrackInterval:
                    txtTimeInterval.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.SMSTrackTimes:
                    txtTrackingCount.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                // GPRS追踪
                case EnumE01Offset.GPRSConnectWay:
                    cmbGPRSConnectModel.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.TrackInterval:
                    txtGPRSInterval.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.EngineOffInterval:
                    txtEngineClosedUploadInterval.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.EngineCheck:
                    chkIgnitionOff.setValue(parseInt(reverseHex(e01data), 16)>0?false:true);
                    break;
                case EnumE01Offset.TrackTimes:
                    txtGPRSTrackingCount.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.IP1:
                    txtIP.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Port1:
                    txtPort.setValue(ASCHexToString(e01data));
                    break;
                case EnumE01Offset.IP2:
                    txtBackupIP.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Port2:
                    txtBackupPort.setValue(ASCHexToString(e01data));
                    break;
                case EnumE01Offset.APN:
                    txtAPN.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.APNUserName:
                    txtAPNUserName.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.APNPassword:
                    txtAPNPassword.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.TrackerID:
                    txtDeviceNumber.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.GPRSAuth:
                    readAuthEx(GPRSStore, e01data, "choosed");
                    break;
                case EnumE01Offset.ProtocolType:
                    cmbProtocolType.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                // 主要参数  
                // GPRS可靠传输方式和休眠模式没有  
                case EnumE01Offset.SMSTimeZone:
                    txtTimeZone.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.GPRSTimeZone:
                    txtGPRSZone.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.DistanceInterval:
                    txtDistanceTractingInterval.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.Turn:
                    txtAngleTurn.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.MaxSpeed:
                    txtOverSpeedAlarm.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.ExternalPowerLow:
                    txtExternalPowerLowValue.setValue((parseFloat(parseInt(reverseHex(e01data), 16))/10).toFixed(1));
                    break;
                case EnumE01Offset.Heartbeat:
                    txtHeartbeatPacketInterval.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.LogInteravl:
                    txtRecorderInterval.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.Tow:
                    txtTowAlarmShakeTime.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                case EnumE01Offset.AccInputGPSleep:
                    cmbSleepModelEx.setValue(parseInt(reverseHex(e01data), 16));
                    break;
                 case EnumE01Offset.LEDOff:
                    chkLEDOff.setValue(parseInt(reverseHex(e01data), 16)>0?true:false);
                    break;
                case EnumE01Offset.BuzzerOff:
                    chkBuzzerOff.setValue(parseInt(reverseHex(e01data), 16)>0?true:false);
                    break;
                // 电子围栏  
                case EnumE01Offset.GeoFence:
                    var index = 0;
                    while (index < e01data.length) {
                        var lng = reverseHex(e01data.substr(index, 8));
                        index += 8;
                        var lat = reverseHex(e01data.substr(index, 8));
                        index += 8;
                        var radius = reverseHex(e01data.substr(index, 8));
                        index += 8;
                        var flag = e01data.substr(index, 2);
                        index += 2;
                        index += 6;
                        if (index <= 32) {
                            txtLng1.setValue((parseFloat(parseInt(lng, 16))/1000000).toFixed(6));
                            txtLat1.setValue((parseFloat(parseInt(lat, 16))/ 1000000).toFixed(6));
                            txtRadius1.setValue(parseInt(radius, 16));
                            check_checkbox(checkboxEnterGEO1, checkboxExitGEO1, flag);
                        } else if (index <= 32 * 2) {
                            txtLng2.setValue((parseFloat(parseInt(lng, 16))/1000000).toFixed(6));
                            txtLat2.setValue((parseFloat(parseInt(lat, 16))/1000000).toFixed(6));
                            txtRadius2.setValue(parseInt(radius, 16));
                            check_checkbox(checkboxEnterGEO2, checkboxExitGEO2, flag);
                        } else if (index <= 32 * 3) {
                            txtLng3.setValue((parseFloat(parseInt(lng, 16))/1000000).toFixed(6));
                            txtLat3.setValue((parseFloat(parseInt(lat, 16))/1000000).toFixed(6));
                            txtRadius3.setValue(parseInt(radius, 16));
                            check_checkbox(checkboxEnterGEO3, checkboxExitGEO3, flag);
                        } else if (index <= 32 * 4) {
                            txtLng4.setValue((parseFloat(parseInt(lng, 16))/1000000).toFixed(6));
                            txtLat4.setValue((parseFloat(parseInt(lat, 16))/1000000).toFixed(6));
                            txtRadius4.setValue(parseInt(radius, 16));
                            check_checkbox(checkboxEnterGEO4, checkboxExitGEO4, flag);
                        } else if (index <= 32 * 5) {
                            txtLng5.setValue((parseFloat(parseInt(lng, 16))/1000000).toFixed(6));
                            txtLat5.setValue((parseFloat(parseInt(lat, 16))/1000000).toFixed(6));
                            txtRadius5.setValue(parseInt(reverseHex(radius), 16));
                            check_checkbox(checkboxEnterGEO5, checkboxExitGEO5, flag);
                        } else if (index <= 32 * 6) {
                            txtLng6.setValue((parseFloat(parseInt(lng, 16))/1000000).toFixed(6));
                            txtLat6.setValue((parseFloat(parseInt(lat, 16))/1000000).toFixed(6));
                            txtRadius6.setValue(parseInt(reverseHex(radius), 16));
                            check_checkbox(checkboxEnterGEO6, checkboxExitGEO6, flag);
                        } else if (index <= 32 * 7) {
                            txtLng7.setValue((parseFloat(parseInt(lng, 16))/1000000).toFixed(6));
                            txtLat7.setValue((parseFloat(parseInt(lat, 16))/1000000).toFixed(6));
                            txtRadius7.setValue(parseInt(reverseHex(radius), 16));
                            check_checkbox(checkboxEnterGEO7, checkboxExitGEO7, flag);
                        } else if (index <= 32 * 8) {
                            txtLng8.setValue((parseFloat(parseInt(lng, 16))/1000000).toFixed(6));
                            txtLat8.setValue((parseFloat(parseInt(lat, 16)) / 1000000).toFixed(6));
                            txtRadius8.setValue(parseInt(reverseHex(radius), 16));
                            check_checkbox(checkboxEnterGEO8, checkboxExitGEO8, flag);
                        }
                    }

                    break;
                // 授权号码  
                case EnumE01Offset.SMSAuth:
                    var index = 0;
                    while (index < e01data.length) {
                        var number = e01data.substr(index, 32);
                        index += 32;
                        var stoe01data = e01data.substr(index, 16);
                        index += 16;
                        var reserve = e01data.substr(index, 16);
                        index += 16;
                        if (index <= 64) {
                            txtAuthNumber1.setValue(ASCHexToString((number)));
                            readAuthEx(SMSStore, stoe01data, "choosed");
                        } else if (index <= 64 * 2) {
                            txtAuthNumber2.setValue(ASCHexToString((number)));
                            readAuthEx(SMSStore, stoe01data, "choosed1");
                        } else if (index <= 64 * 3) {
                            txtAuthNumber3.setValue(ASCHexToString((number)));
                            readAuthEx(SMSStore, stoe01data, "choosed2");
                        } else if (index <= 64 * 4) {
                            txtListenerNumber1.setValue(ASCHexToString((number)));
                        } else if (index <= 64 * 5) {
                            txtListenerNumber2.setValue(ASCHexToString((number)));
                        }
                    }
                    break;
                // 短信事件字符  
                case EnumE01Offset.Input1Activate_Message:
                    txtInput1Activate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Input2Activate_Message:
                    txtInput2Activate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Input3Activate_Message:
                    txtInput3Activate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Input4Activate_Message:
                    txtInput4Activate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Input5Activate_Message:
                    txtInput5Activate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Input1NotActivate_Message:
                    txtInput1NotActivate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Input2NotActivate_Message:
                    txtInput2NotActivate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Input3NotActivate_Message:
                    txtInput3NotActivate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Input4NotActivate_Message:
                    txtInput4NotActivate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Input5NotActivate_Message:
                    txtInput5NotActivate_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.BuiltinLowVoltage_Message:
                    txtBuiltinLowVoltage_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.OutlayLowVoltage_Message:
                    txtOutlayLowVoltage_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.OverSpeedAlarm_Message:
                    txtOverSpeedAlarm_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.EnterGEO_Message:
                    txtEnterGEO_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.ExitGEO_Message:
                    txtExitGEO_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.OutlayPowerOn_Message:
                    txtOutlayPowerOn_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.OutlayPowerOff_Message:
                    txtOutlayPowerOff_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.NotFixGPRS_Message:
                    txtNotFixGPRS_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.FixGPRS_Message:
                    txtFixGPRS_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.EnterSleep_Message:
                    txtEnterSleep_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.ExitSleep_Message:
                    txtExitSleep_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.GPRSAntennaCut_Message:
                    txtGPRSAntennaCut_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.Reboot_Message:
                    txtReboot_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.CrashAlarm_Message:
                    txtCrashAlarm_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.DistanceTracing_Message:
                    txtDistanceTracing_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.DemandInfoNow_Message:
                    txtDemandInfoNow_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.IntervalTracting_Message:
                    txtIntervalTracting_Message.setValue(ASCHexToString((e01data)));
                    break;
                case EnumE01Offset.TowAlarm_Message:
                    txtTowAlarm_Message.setValue(ASCHexToString((e01data)));
                    break;
                // 拍照事件  
                case EnumE01Offset.PhotoAuth:
                    readAuthEx(PhotoStore, e01data, "choosed");
                    break;
            }
        };
        // 判断读取checkbox的状态
        function check_checkbox(checkbox1, checkbox2, flag) {
            if (flag == 00) {
                checkbox1.setValue(false);
                checkbox2.setValue(false);
            } else if (flag == 01) {
                checkbox1.setValue(true);
                checkbox2.setValue(false);
            } else if (flag == 02) {
                checkbox1.setValue(false);
                checkbox2.setValue(true);
            } else if (flag == 03) {
                checkbox1.setValue(true);
                checkbox2.setValue(true);
            }
        };
        
        //store to Hex Auth
        function getAuthEx(sto, name, isphotoauth) { //授权 store
            var strbinB = padLeft('', '0', 64);
            var strbinH = padLeft('', '0', 64);
            var index;
            sto.each(function(record) {
                index = parseInt(record.get("valueid"));
                var checked = record.get(name);
                if (checked) {
                    if (index <= 64) {
                        var byteindex = parseInt((index-1) / 8);
                        var bytebitindex = (7 - ((index % 8) - 1)) %8;
                        strbinB = replacechr(strbinB, byteindex * 8 + bytebitindex, "1");
                    }
                    else {
                        var index2 = (index - 64);
                        var byteindex = parseInt((index2-1) / 8);
                        var bytebitindex = (7 - ((index2 % 8) - 1)) % 8;
                        strbinH = replacechr(strbinH, byteindex * 8 + bytebitindex, "1");
                    }
                }
            });

            var strHex = padLeft(parseInt(strbinB, 2).toString(16), '0', 16) + padLeft(parseInt(strbinH, 2).toString(16), '0', 16);
            strHex = strHex.toUpperCase();
            return strHex;
        }

        // 通过读取到的Parameter修改store内的值
        function readAuthEx(sto, authdata, changeParameterName) {
            var i;
            var authindex = 0; //授权位
            for (i = 0; i < authdata.length / 2; i++) {
                var dHex = authdata.substr(i * 2, 2);
                var dBin = padLeft(parseInt(dHex, 16).toString(2), '0', 8); //get bin string
                authindex = i * 8;
                var j;
                for (j = 0; j < 8; j++) {
                    var checked = dBin.substr(8 - j - 1, 1) == "1" ? true : false;
                    var rowindex = sto.find("valueid", (authindex + j + 1).toString());
                    if (rowindex >= 0) {
                        var record = sto.getAt(rowindex);
                        record.set(changeParameterName, checked);
                    }
                }     
            }
            return sto;
        };
        // 反转16进制字符
        function reverseHex(str) {
            var str = str.toString();
            var arr = [];
            index = 0;
            var i;
            for (i = 0; i < str.length; i++) {
                arr[index] = str.substr(i, 2);
                index++;
                i++;
            }

            var returnstr = '';
            for (var index = arr.length - 1; index >= 0; index--) {
                returnstr += arr[index];
            }
            return returnstr;
        };
                
        var win = new Ext.Window({
            title: _SettingTool_SettingTools + (trackername == null?"": "(" +trackername +")" ) ,
            border: 'true',
            width: 800,
            minWidth: 800,
            height: 500,
            // renderTo:'window',
            // draggable : false,
            tbar: toolabr,
            layout: 'fit',
            items: [tabs],
            minimizable: true,
             listeners: {
                'minimize': function() {
                    addTaskButtonForWindow(win);
                }
            }
        });
        win.show();

        win.on('close', function(obj) {
            g_PEWindowObject = null;
            timer = null;
            if (sssid != null)
                g_PEWindowDictionary.Remove(sssid);
        });
        
        g_PEWindowObject = this;

}

        
